﻿@using Newtouch.Infrastructure;
@{
    ViewBag.Title = "PatientHistoricalOrders";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="tabGrid">
    <div>
        <div class="gridPanel">
            <table id="gridList" rel="tabGrid"></table>
            <div id="gridPager"></div>
        </div>
    </div>
</form>

<script>
    var zyh = $.request("zyh");
    $(function () {
        gridList();
    });
    var returnzyh = "";
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "@Url.Action("GetPatientQuery")",
            postData: { zyh: zyh},
            height: $(window).height() - 70,
            unwritten: false,
            rownumbers: true,
            colModel: [
                { label: '住院号', name: 'zyh', width: 40, align: 'left' },
                { label: '姓名', name: 'xm', width: 50, align: 'left' },
                { label: '性别', name: 'xb', width: 30, align: 'left' },
                { label: '入院日期', name: 'ryrq', width: 70, align: 'left' },
                { label: '出院日期', name: 'cyrq', width: 70, align: 'left' },
                { label: '入院诊断', name: 'ryzd', width: 120, align: 'left' },
                { label: '出院诊断', name: 'cyzd', width: 120, align: 'left' },
            ],
            viewrecords: true,
            sortname: 'zh desc',
            ondblClickRow: function (rowid) {
                var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
                if (!(seleRowid)) {
                    $.modalAlert("请选中一条信息", 'warning');
                    return;
                }
                var keyValue = $("#gridList").jqGridRowValue().zyh;
                var ryrq = $("#gridList").jqGridRowValue().ryrq;
                var xm = $("#gridList").jqGridRowValue().xm;
                var xb = $("#gridList").jqGridRowValue().xb;
                var cyrq = $("#gridList").jqGridRowValue().cyrq;
                var ryzd = $("#gridList").jqGridRowValue().ryzd;
                var cyzd = $("#gridList").jqGridRowValue().cyzd;
                returnzyh = keyValue + "," + ryrq + "," + xm + "," + xb + "," + cyrq + "," + ryzd + "," + cyzd;
                ;
                submitForm();
            },
            onSelectRow: function (rowid, status) {
                var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
                if (!(seleRowid)) {
                    $.modalAlert("请选中一条信息", 'warning');
                    return;
                }
                var keyValue = $("#gridList").jqGridRowValue().zyh;
                var ryrq = $("#gridList").jqGridRowValue().ryrq;
                var xm = $("#gridList").jqGridRowValue().xm;
                var xb = $("#gridList").jqGridRowValue().xb;
                var cyrq = $("#gridList").jqGridRowValue().cyrq;
                var ryzd = $("#gridList").jqGridRowValue().ryzd;
                var cyzd = $("#gridList").jqGridRowValue().cyzd;
                returnzyh = keyValue + "," + ryrq + "," + xm + "," + xb + "," + cyrq + "," + ryzd + "," + cyzd;
                ;
                submitForm();
            },
            onSelectAll: function (aRowids, status) {
                //gridztcheck(aRowids, status);
            }
        });
    }
    //function gridztcheck(aRowids, status){
    //    CalculateInsPresJYAmount();
    //}

    //计算申请单金额
    //function CalculateInsPresJYAmount() {
    //    var totalAmount = 0.00;
    //    var allData = $("#gridList").jqGrid('getRowData_AllLine', true, true);
    //    $.each(allData, function () {
    //        totalAmount += parseFloat(this.dj) * parseFloat(this.sl);
    //    });
    //    $("#gridList").jqGrid("setCaption", "合计：" + "<label style='color:red;'>￥"
    //        + totalAmount.toFixed(2) + "</label>");   //重置caption属性值
    //}

    function submitForm() {
        if (returnzyh==""){
            $.modalAlert("请选择历史病人信息进行复制", 'warning');
            return;
        }
       
        return returnzyh;
    }
</script>


